/**
 * 装车登记审核管理初始化
 */
var CarryBasicInformation = {
    id: "CarryBasicInformationTable",	//表格id
    seItem: null,		//选中的条目
    table: null,
    layerIndex: -1
};

/**
 * 初始化表格的列
 */
CarryBasicInformation.initColumn = function () {
    return [
        {field: 'selectItem', radio: true},
            {title: '装车编号', field: 'carryId', visible: true, align: 'center', valign: 'middle'},
            {title: '审核状态', field: 'carryState', visible: true, align: 'center', valign: 'middle'},
            {title: '制单员', field: 'carryTradePerson', visible: true, align: 'center', valign: 'middle'},
            {title: '车次', field: 'carryNumber', visible: true, align: 'center', valign: 'middle'},
            {title: '装车日期', field: 'carryDate', visible: true, align: 'center', valign: 'middle'},
            {title: '车号', field: 'carryCarId', visible: true, align: 'center', valign: 'middle'},
            {title: '驾驶员', field: 'carryCarDriver', visible: true, align: 'center', valign: 'middle'},
            {title: '联系电话', field: 'carryCarDriverTell', visible: true, align: 'center', valign: 'middle'},
            {title: '手机', field: 'carryCarDriverMobile', visible: true, align: 'center', valign: 'middle'},
            {title: '物流线路', field: 'carryRouteId', visible: true, align: 'center', valign: 'middle'},
            {title: '始发站', field: 'carryRouteStart', visible: true, align: 'center', valign: 'middle'},
            {title: '到站', field: 'carryRouteEnd', visible: true, align: 'center', valign: 'middle'},
            {title: '中转站', field: 'carryRouteTransferStation', visible: true, align: 'center', valign: 'middle'},
            {title: '备注', field: 'carryRemark', visible: true, align: 'center', valign: 'middle'}
    ];
};

/**
 * 检查是否选中
 */
CarryBasicInformation.check = function () {
    var selected = $('#' + this.id).bootstrapTable('getSelections');
    if(selected.length == 0){
        Feng.info("请先选中表格中的某一记录！");
        return false;
    }else{
        CarryBasicInformation.seItem = selected[0];
        return true;
    }
};

/**
 * 打开查看装车登记审核详情
 */
CarryBasicInformation.openCarryBasicInformationDetail = function () {
    if (this.check()) {
        var index = layer.open({
            type: 2,
            title: '装车登记审核详情',
            area: ['800px', '500px'], //宽高
            fix: false, //不固定
            maxmin: true,
            content: Feng.ctxPath + '/carryBasicInformation/carryBasicInformation_updatecheck/' + CarryBasicInformation.seItem.id
        });
        this.layerIndex = index;
        layer.full(index);
    }
};

/**
 * 删除装车登记审核
 */
CarryBasicInformation.delete = function () {
    if (this.check()) {
        var ajax = new $ax(Feng.ctxPath + "/carryBasicInformation/delete", function (data) {
            Feng.success("删除成功!");
            CarryBasicInformation.table.refresh();
        }, function (data) {
            Feng.error("删除失败!" + data.responseJSON.message + "!");
        });
        ajax.set("carryBasicInformationId",this.seItem.id);
        ajax.start();
    }
};

/**
 * 查询装车登记审核列表
 */
CarryBasicInformation.search = function () {
    var queryData = {};
    queryData['condition'] = $("#condition").val();
    CarryBasicInformation.table.refresh({query: queryData});
};

$(function () {
    var defaultColunms = CarryBasicInformation.initColumn();
    var table = new BSTable(CarryBasicInformation.id, "/carryBasicInformation/listcheck", defaultColunms);
    table.setPaginationType("server");
    CarryBasicInformation.table = table.init();
});
